SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

ALTER   function f_getalllay(@bid int,@bno int)
returns varchar(500) as
begin
  declare @uselay int

  select @uselay=p_paramvalue from ts_parameters where p_paramnm='uselay'
  if isnull(@uselay,0)=0
    return '' 
  declare @layname varchar(60),@quantity numeric(18,4),@alllay varchar(500)
  set @alllay=''
  declare laycur cursor local forward_only static optimistic for 
    select l.name,dl.quantity from tb_depotlay dl left join td_lay l on dl.layid=l.id
      where dl.bid=@bid and bno=@bno
  open laycur
  fetch next from laycur into @layname,@quantity
  while (@@fetch_status = 0)
  begin
    set @alllay=@alllay+@layname+':'+cast(@quantity as varchar)+','
    fetch next from laycur into @layname,@quantity
  end
  close laycur
  deallocate laycur
  if @alllay<>''
    set @alllay=substring(@alllay,1,len(@alllay)-1)
  return @alllay
end






GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

